<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<link href="joju.css" rel="stylesheet" type="text/css" />

<link href="http://localhost:7001/RESOLVEApp/css/idelta.css"/>
<link href="http://localhost:7001/RESOLVEApp/css/tabbed_panel.css"/>
<link href="http://localhost:7001/RESOLVEApp/css/application.css"/>
<script type="text/javascript" src="http://localhost:7001/RESOLVEApp/js/ajax-basics.js"/>
<script type="text/javascript" src="http://localhost:7001/RESOLVEApp/js/ajax-basics.js"/>
<script type="text/javascript" src="http://localhost:7001/RESOLVEApp/js/dojo/dojo.js"/>
<script type="text/javascript" src="./js/dojo/dojo.js"/>
<script type="text/javascript" src="http://localhost:7001/RESOLVEApp/js/dojo/dojo.js"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>


<script type="text/javascript">
	var djConfig = { isDebug: false };
</script>
<script type="text/javascript" src="http://localhost:7001/RESOLVEApp/js/dojo/dojo.js">/*_*/</script>


<script type="text/javascript">
/* Initial Nodes */
var treeDat = {
	treeNodes: [
		{ title:"Customer" }
	]
};
</script>

<script type="text/javascript">
/* Initial Nodes */



 function titleClicked(event){
	  var e=window.event;
	  var text = event.srcElement.innerText;
	  text = text.substring(text.indexOf(':')+1);	 
		   var temp = new Array();
		   temp = text.split('|');
		   var url = "http://localhost:7001/RESOLVEApp/SvnTreeServlet?CustomerID="+escape(temp[1]);
		   sendRequest(url);
  }


 function onNodeClick(event){
			var e=window.event;
			var txt = event.srcElement.innerText;     
			var svnpath = document.getElementById("Path").value+"/"+txt;
			alert (svnpath);
			window.opener.insertpath(svnpath);
			window.close(); 
  }



</script>
<script>


var request;
var xmlHttp ;
var functionname;
var repo;
function setpath()
{
	repo = window.opener.document.getElementById("repo").value;
	document.getElementById("Path").value=repo;
	alert(document.getElementById("Path").value);
}

function getdata(str)
{
   // this servelt calling used for get details of customer on click of the node 
    functionname="getdata";
   var url = "http://localhost:7001/RESOLVEApp/SvnTreeServlet?CustomerAccountID="+str;
   alert(url);
   sendRequest(url);

}


function getRequestObject() {
  if (window.ActiveXObject) {
    return(new ActiveXObject("Microsoft.XMLHTTP"));
  } else if (window.XMLHttpRequest) {
    return(new XMLHttpRequest());
  } else {
    return(null);
  }
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function saveRequest(address) {
  xmlHttp = GetXmlHttpObject();
  xmlHttp.onreadystatechange = showSaveResponseText;
  xmlHttp.open("GET", address, false);
  xmlHttp.send(null);
}


function showSaveResponseText() {
  if ((xmlHttp.readyState == 4) &&
      (xmlHttp.status == 200)) {


              // alert(xmlHttp.responseText);

              // var xmlDoc=xmlHttp.responseXML.documentElement;
  }
}



function sendRequest(address) {
  xmlHttp = GetXmlHttpObject();
  xmlHttp.onreadystatechange = showResponseText;
  xmlHttp.open("GET", address, true);
  xmlHttp.send(null);
}


function showResponseText() {
  if ((xmlHttp.readyState == 4) &&
      (xmlHttp.status == 200)) {


              // alert(xmlHttp.responseText);
  
       }


}





</script>



<script type="text/javascript">

var pathstr = null;

dojo.addOnLoad(function(){
	dojo.require("dojo.lang.*");
	dojo.require("dojo.widget.Tree");
	dojo.require("dojo.widget.TreeNode");
	dojo.require("dojo.widget.TreeRPCController");
	

var TreeBuilder = {
	buildTreeNodes:function (dataObjs, treeParentNode){
		for(var i=0; i<dataObjs.length;i++){
			var node =  dojo.widget.createWidget("TreeNode",{
				title:dataObjs[i].title,
				isFolder: true,
				widgetId:(((treeParentNode)?treeParentNode.widgetId:"root_")+"_"+i)
			});
			treeParentNode.addChild(node);
			treeParentNode.registerChild(node,i);
		}
	},
	buildTree:function (){
		var myTreeWidget = dojo.widget.createWidget("Tree",{
			widgetId:"myTreeWidget",
			expandIconSrcPlus:"http://localhost:7001/RESOLVEApp/images/package_obj.gif", 
			 expandIconSrcMinus:"http://localhost:7001/RESOLVEApp/images/package_obj.gif", 
			 iconWidth:13, 
			 iconHeight:13 


		});
		this.buildTreeNodes(treeDat.treeNodes,myTreeWidget);
		var treeContainer = document.getElementById("myWidgetContainer");
		var placeHolder = document.getElementById("treePlaceHolder");
		treeContainer.replaceChild(myTreeWidget.domNode,placeHolder);
	}
}

TreeBuilder.buildTree();
	var myRpcController = dojo.widget.createWidget("TreeRPCController",{
			widgetId:"treeController",
			RPCUrl:"http://localhost:7001/RESOLVEApp/SvnTreeServlet"
		});
dojo.event.topic.subscribe("nodeSelected",
			 function(message) { alert(message.node.title+" selected"); });

	myRpcController.onTreeClick = function(message){
		var node = message.source;
		var widget = dojo.widget.getWidgetById('treeController');
		var txt = new String(node);
		if(txt.indexOf("Customer") ==-1)
			{
				
				var label = node.title;
				 var pathhid=document.getElementById("Path").value;
				// alert(pathhid);
				if (pathhid !== null)
				{
					pathhid = pathhid+"/"+label;
					document.getElementById("Path").value = pathhid;
					alert(pathhid);
				}
				 //var breadcrumbStr = node.title;
				 //var parent = node.getParent();
				 //breadcrumbStr = parent.title + " &raquo; " + breadcrumbStr;
				
				/*
				//create the breadcrumb string
					while (parent) {
					  if (parent.indent > 0)  //don't include the root
						breadcrumbStr = parent.title + " &raquo; " + breadcrumbStr;

					  parent = parent.getParent();
				 }
				*/
				// alert (breadcrumbStr);

				/*
				var pathstr;
				pathstr = label+"/";
				
				var node  =node.getParent();				
				
				while ((node.title.indexOf("Customer")) == -1)
				  {
					lable = node.title;
					pathstr=pathstr+lable+"/";
					node  =node.getParent();

				  }
				  alert("path :"+pathstr);
				  */
				  //pathstr = "http://localhost:7001/RESOLVEApp/SvnTreeServlet?CustomerID=http://svn.svnkit.com/repos/svnkit/"+label;
				  widget.RPCUrl = "http://localhost:7001/RESOLVEApp/SvnTreeServlet?CustomerID="+pathhid;
				  
			}

		else
		{
		widget.RPCUrl = "http://localhost:7001/RESOLVEApp/SvnTreeServlet?CustomerID="+repo;
		}
		if (node.isExpanded){
			this.expand(node);
		} else {
			this.collapse(node);
		}

	}



	myRpcController.onTitleClick = function(message){
		var node = message.source;
		var text = node.objectId;
		widget.RPCUrl = "http://localhost:7001/RESOLVEApp/SvnTreeServlet?CustomerID="+text;
		if (node.isExpanded){
			this.expand(node);
		} else {
			this.collapse(node);
		}

	}

	var treeContainer = document.getElementById("myWidgetContainer");
	treeContainer.appendChild(myRpcController.domNode);
	myRpcController.listenTree(dojo.widget.manager.getWidgetById("myTreeWidget"));
	});
</script>

</head>

</head>


<body onLoad="setpath()">
<form name="Svntreelist"  method="POST">
<table border="0" cellspacing="0" cellpadding="0" usemap="#Map">
  <tr>
  <td>

<input type="hidden" name="Path" id ="Path" value ="0" >

  <div id="myWidgetContainer"
                   style="width:1500; height:557px; overflow-x:auto;overflow-y:auto;">
	
	
<logic:notEqual name="RecordCount" value="0">

	<span id="treePlaceHolder"
		
		Loading Customertree ...
	</span>
</logic:notEqual>

<logic:equal name="RecordCount" value="0">

<span id="UserInforslt">Search criteria Customer does not exist</span>

</logic:equal>

	</div>


	</td>

  </tr>
</table>


<map name="Map" id="Map"><area shape="rect" coords="117,195,213,217" href="tree_main.jsp" target="treemainFrame" />
</map>
</form>
</body>
</html>
